#include <QApplication>
#include <QDebug>
#include <QFile>
#include "grammar/python3/PythonGrammar30.h"
#include "grammar/python3/PythonGrammar30TokenManager.h"
#include "Object.h"
#include <QtTest/QtTest>
#include "TestParser.h"
#include "astng/ModulesMgr.h"
#include "astng/Scopes/ModuleScope.h"
#include "pyeditor/PyEditor.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    /*QFile file("/usr/lib/python3.2/decimal.py");
    if (file.open(QIODevice::ReadOnly)){
        QString test = file.readAll();
        file.close();

        CharStream stream(test, test.length(), 0, 0);
        PythonGrammar30TokenManager in(&stream);
        //connect(&err, SIGNAL(error(QString,int,int)), SLOT(parseError(QString,int,int)));
        PythonGrammar30 grammar(&in);

        ModulePtr newRoot = grammar.file_input().dynamicCast<Module>();

        //qDebug() << out->toString();
    }*/

    //Modules::getModules()->moduleByFileName("cache/copy.py");
    //Modules::getModules()->addModuleByFileName("/usr/lib/python3.2/site-packages/oursql.cpython-32mu.so");
    //Modules::getModules()->addModuleByFileName("/usr/lib/python3.2/lib-dynload/crypt.cpython-32mu.so");
    //Modules::getModules()->addModuleByFileName("/usr/lib/python2.7/lib-dynload/crypt.so");
    //Modules::getModules()->addModuleByFileName("out.py");
    //Modules::getModules()->addModuleByFileName("/usr/lib/python3.2/lib-dynload/time.cpython-32mu.so");
    //Modules::getModules()->addModuleByFileName("functools.py");
    //Modules::getModules()->addModuleByFileName("/usr/lib/python3.2/site-packages/oursql.cpython-32mu.so");
    //Modules::getModules()->addModuleByFileName("/usr/lib/python3.2/lib-dynload/math.cpython-32mu.so");
    //Modules::getModules()->addModuleByFileName("/usr/lib/python3.2/lib-dynload/time.cpython-32mu.so");
    //Modules::getModules()->moduleByFileName("py.py");
    //ModulesMgr::instance().moduleByFileName("/usr/lib/python3.2/ast.py");
    //ModulesMgr::instance().moduleByName("weakref");
    //ModulesMgr::instance().moduleByFileName("/usr/lib/python3.2/locale.py");
    /*
    ModuleScope* sc = ModulesMgr::instance().moduleByFileName("py.py", false);
    foreach(Error e, sc->errorList())
        qDebug() << e.msg;
    delete sc;
    */
    ModuleScope *sc = ModulesMgr::instance().moduleByFileName("/usr/lib/python3.2/decimal.py");
    //ModuleScope *sc = ModulesMgr::instance().moduleByFileName("py.py", false);
    delete sc;
    //Modules::getModules()->end();
    //PyEditor edt;
    //edt.load("py.py");
    //edt.load("/usr/lib/python3.2/locale.py");
    //edt.resize(600, 500);
    //edt.show();
    //return a.exec();
}


//QTEST_MAIN(TestParser)
